// 武器升级插件

string author = "Live";
string pluginName = "WeaponUpgrade 武器升级插件";
string version = "1.1";

// 插件初始化
void OnPluginInit()
{
    // 设置插件信息
    PluginData::SetAuthor(author);
    PluginData::SetName(pluginName);
    PluginData::SetVersion(version);

    // 加载后提示信息
    ThePresident.InfoFeed("插件:"+pluginName+"| 版本:"+version+"| 作者:"+author,false);

    // 当玩家说
    Events::Player::PlayerSay.Hook( @PlayerSay );
    // 执行菜单项
    Events::Player::OnMenuExecuted.Hook( @OnMenuExecuted );
}

HookReturnCode PlayerSay(CTerrorPlayer@ pPlayer, CASCommand@ pArgs)
{
    string arg = pArgs.Arg(1);
    if(arg == "/wu"){
        menu(pPlayer);
    }
    return HOOK_CONTINUE;
}

void menu(CTerrorPlayer@ pPlayer){
    Menu pMenu;
    pMenu.SetID("menu");
    pMenu.SetTitle("菜单Menu");
    pMenu.AddItem("照明Flashlight");
    pMenu.AddItem("双倍伤害DoubleDamage");
    pMenu.AddItem("火焰FireDamage");
    pMenu.AddItem("溶解Dissolve");
    pMenu.AddItem("爆炸Explosive");
    pMenu.AddItem("资金加成MoneyBoost");
    pMenu.AddItem("清除Clear");
    pMenu.Display(pPlayer,-1);
}

HookReturnCode OnMenuExecuted(CTerrorPlayer@ pPlayer, const string &in szID, int &in iValue){
    if(szID == "menu"){
        CBaseEntity@ BaseWeapon = pPlayer.GetCurrentWeapon();
        CTerrorWeapon@ Weapon = ToTerrorWeapon(BaseWeapon);
        switch(iValue){
            case 1:
                Weapon.UpgradeModule(SET,k_eFlashlight);
                Chat.PrintToChat(pPlayer,"{hotpink}升级武器照明成功！");
                break;
            case 2:
                Weapon.UpgradeModule(SET,k_eDoubleDamage);
                Chat.PrintToChat(pPlayer,"{hotpink}升级武器双倍伤害成功！");
                break;
            case 3:
                Weapon.UpgradeModule(SET,k_eFireDamage);
                Chat.PrintToChat(pPlayer,"{hotpink}升级武器火焰成功！");
                break;
            case 4:
                Weapon.UpgradeModule(SET,k_eDissolve);
                Chat.PrintToChat(pPlayer,"{hotpink}升级武器溶解成功！");
                break;
            case 5:
                Weapon.UpgradeModule(SET,k_eExplosive);
                Chat.PrintToChat(pPlayer,"{hotpink}升级武器爆炸成功！");
                break;
            case 6:
                Weapon.UpgradeModule(SET,k_eMoneyBoost);
                Chat.PrintToChat(pPlayer,"{hotpink}升级武器资金加成成功！");
                break;
            case 7:
                Weapon.UpgradeModule(REM,k_eFlashlight);
                Weapon.UpgradeModule(REM,k_eDoubleDamage);
                Weapon.UpgradeModule(REM,k_eFireDamage);
                Weapon.UpgradeModule(REM,k_eDissolve);
                Weapon.UpgradeModule(REM,k_eExplosive);
                Weapon.UpgradeModule(REM,k_eMoneyBoost);
                Chat.PrintToChat(pPlayer,"{hotpink}清除所有武器升级成功！");
                break;
        }
    }
    return HOOK_CONTINUE;
}
